/**
 * @USER: Administrator
 * @DATE: 2024/9/17 下午5:15
 * @VERSION: 1.0.0
 */
public class LC941 {
    public static void main(String[] args) {
        LC941 lc941 = new LC941();
        System.out.println(lc941.validMountainArray(new int[]{1, 3, 2}));
    }

    public boolean validMountainArray(int[] arr) {
        if (arr.length<3) return false;

        // 从哪开始降序
        int descIndex = 0;

        // 判断升序
        for (int i = 1; i < arr.length; i++) {
            if (arr[i]<arr[i-1]){
                descIndex = i-1;
                break;
            } else if (arr[i]<=arr[i-1]) {
                return false;
            }
        }

        // 判断降序
        for (int i = descIndex;i<arr.length;i++) {
            if (arr[i]>=arr[i-1]) {
                return false;
            }
        }

        return true;
    }

}
